from core.nodes.base import CoreNode
from core.services.coreservices import CoreService
from typing import Dict, List, Tuple
 
class CtrService(CoreService):
 
    name: str = "CtrService"
    group: str = "SDN"
 
    configs: Tuple[str, ...] = ("CtrService.sh",)
    startup: Tuple[str, ...] = ("bash CtrService.sh",)
 
    @classmethod
    def generate_config(cls, node: CoreNode, filename: str) -> None:
 
        cfg = "#!/bin/sh\n"
        # start up the pox controller

        cfg += "python2 /home/username/pox/pox.py forwarding.l2_pairs\n"
        return cfg

# 2022/01/10 add support to pof Controller
class PofCtr(CoreService):
    name: str = "PofCtr"
    group: str = "SDN"
 
    configs: Tuple[str, ...] = ("PofCtr.sh",)
    startup: Tuple[str, ...] = ("bash PofCtr.sh",)
 
    @classmethod
    def generate_config(cls, node: CoreNode, filename: str) -> None:
 
        cfg = "#!/bin/sh\n"
        # replace username to Host'username
        cfg += "python /home/username/my_file/PCTRL-master/pox.py openflow.pof_01 --port=6633 core1-drop\n"
        return cfg